package com.unitd.frame.comm.utils.http;

import java.net.HttpURLConnection;

/**
 * @desc http远程调用响应信息封装对象
 * @filename HttpResponseEntity.java
 * @copyright www.unitd.com
 * @author Hudan
 * @version 1.0
 * @date 2017/4/29
 */
public class HttpResponseEntity {
	/** HTTP请求响应状态码 */
	private int statusCode;
	/** HTTP请求响应内容 */
	private String body;
	/** HTTP请求响应异常(如果有) */
	private Exception exception;

	public HttpResponseEntity() {
	}

	public HttpResponseEntity(int statusCode, String body) {
		super();
		this.statusCode = statusCode;
		this.body = body;
	}

	public HttpResponseEntity(int statusCode, Exception exception) {
		this.statusCode = statusCode;
		this.exception = exception;
	}

	public int getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public boolean isSuccessed() {
		return statusCode == HttpURLConnection.HTTP_OK;
	}

	public Exception getException() {
		return exception;
	}

	public void setException(Exception exception) {
		this.exception = exception;
	}

	@Override
	public String toString() {
		return "HttpResponseEntity [statusCode=" + statusCode + ", body=" + body + "]";
	}
}